const app = getApp();
Page({

  data: {
    isAdmin: false
  },

  //关于我们
  aboutUs:function()
  {
    var topic = 
    {
      type:"resource",
      url:"https://m.gitee.com/zhanghejie/jeexjj_about_us",
      title:"关于我们",
      summary: "我们的宗旨：助力开发者快速搭建项目，助力商家布局互联网应用。"
    };
    let data = JSON.stringify(topic);
    wx.navigateTo({
      url: '/pages/article/article?data=' + data
    })
  },

  onLoad: function (options) {
    if (null != app.globalData.openid) {
      this.setData({isAdmin: app.globalData.isAdmin});
      return;
    }

    //用户登陆记录openid
    // 调用云函数
    wx.cloud.callFunction({
      name: 'login',
      data: {},
      success: res => {
        console.log('[云函数] [login] user openid: ', res.result.openid)
        app.globalData.openid = res.result.openid.openId;
        if ("opyCK5bPsmGzN7dVTTVkuCtUifps" == res.result.openid.openId) {
          app.globalData.isAdmin = true;
        }
        console.info(app.globalData);
      },
      fail: err => {
        console.error('[云函数] [login] 调用失败', err)
      }
    })
  },

  onReady: function () {
  },
  onShow: function () {
  },

  onHide: function () {
  },

  onUnload: function () {
  },

  onPullDownRefresh: function () {
 
  },

  onReachBottom: function () {

  },

  onShareAppMessage: function () {

  }
})